package algorithm.leetcode.problem_88;

public class answer_1 {
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        if (nums2.length == 0) {
            return;
        }
        int[] help = new int[m + n];
        int i = 0;
        int p1 = 0;
        int p2 = 0;
        while (p1 < m && p2 < nums2.length) {
            help[i++] = nums1[p1] < nums2[p2] ? nums1[p1++] : nums2[p2++];
        }
        while (p1 < m) {
            help[i++] = nums1[p1++];
        }
        while(p2 < nums2.length) {
            help[i++] = nums2[p2++];
        }
        for (int j = 0; j < m + n; j++) {
            nums1[j] = help[j];
        }
    }

    public static void main(String[] args) {
        int[] nums1 = {0};
        int[] nums2 = {1};
        merge(nums1,0,nums2,1);
    }
}
